package next.Functionality;

import next.TemplateActivity.R;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;

public class NotificationFunctionality extends AudioVideoFunctionality {

	// --Variables--
	protected Integer notificationID = 0;
	protected CharSequence notificationFrom = "System Alarm";
	protected CharSequence notificationMessage = "Meeting with customer at 3pm...";
	protected Integer notificationIcon=R.drawable.icon;
	
	//-- When a notification is needed this method set, create and start notification.
	public void CreateNotification (String from, String message, Integer icon)
	{
		this.notificationIcon=icon;
		this.notificationFrom=from;
		this.notificationMessage=message;
		displayNotification();
	}

	/** Called to show notification previously settled */
	private void displayNotification() {
		// ---PendingIntent to launch activity if the user selects
		Intent i = new Intent("next.SupportFunctionality.NotificationView");
		i.putExtra("notificationID", notificationID);
		// --PendigIntent: context,request code, intent, flags.
		PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, i, 0);

		NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
		Notification notif = new Notification(notificationIcon,
				"Reminder: Meeting starts in 5 minutes",
				System.currentTimeMillis());
		// --Setting Notification details.--
		notif.setLatestEventInfo(this, notificationFrom, notificationMessage, pendingIntent);
		// ---100ms delay, vibrate for 250ms, pause for 100 ms and
		// then vibrate for 500ms---
		notif.vibrate = new long[] { 100, 250, 100, 500 };
		nm.notify(notificationID, notif);
		
		//--Giving a unique number to every notification.--
		notificationID++;
		
	}

}
